package com.memento.gameExample;

//游戏角色里面保存着 游戏角色的实时状态
public class GameRole {

    private int vit ; //攻击力

    private int def ; //抵抗力

    //构造器
    public GameRole(int vit, int def) {
        this.vit = vit;
        this.def = def;
    }

    //备份一个状态
    public Memento createMemento(){
        return new Memento(vit, def);
    }

    //数据角色当前的状态
    public void getCurrentState(){
        System.out.println("【攻击力】：" + vit +"  【抵抗力】：" + def);
    }

    //通过备份的对象，恢复到之前的状态
    public void recoverStateFromMomento(Memento memento){
        vit = memento.getVit();
        def = memento.getDef();
    }

    public int getVit() {
        return vit;
    }

    public void setVit(int vit) {
        this.vit = vit;
    }

    public int getDef() {
        return def;
    }

    public void setDef(int def) {
        this.def = def;
    }
}
